<?php 
class bing
{
	/*
	获取bing每日图片
	Author Kraus
	*/

	private $image_url_base;
	
	public function __construct()
	{
		$this->image_url_base='http://cn.bing.com/';

	}
		

	private function image_json_decode($json_url)
	{
		$data_json=file_get_contents($json_url);
		$decode_result=json_decode($data_json);

		return $decode_result;
	}

	public function get_all_image_url()
	{
		for ($i=1; $i <= 7  ; $i++) 
		{ 
			$image_url[$i]=$this->get_one_url($i);
		}
		
		return $image_url;
	}

	public function get_one_url($num=1)
	{
		if($num>7 || $num <0)
			return '别闹，这里面没东西！';
		$json_url='http://www.bing.com/HPImageArchive.aspx?format=js&idx=' . $num. '&n=1&mkt=zh-CN';	
		
		$image_result = $this->image_json_decode($json_url);
		
		foreach ($image_result as $value) 
		{
			$image_array=(array)$value[0];
			$image_url_get=$image_array['url'];
			$image_info=$image_array['copyright'];
			break;
		}

		$image_url=$this->image_url_base . $image_url_get;
		return $image_url;
	}
	
	
}
	

?>